package com.mikelouis.test.scala.proginscala.chapter12

/**
 * Created by yuazhu on 1/12/2015.
 */
/**
 * 类Frog是AnyRef（Philosophical的超类）的子类并混入了Philosophical
 *
 * 类Frog都继承了Philosophical的philosophize实现
 *
 * 或者，Frog也可以重载philosophize方法。语法与重载超类中定义的方法一样
 */
class Frog extends Philosophical {
  override def toString = "frog"

  override def philosophize(): Unit = println("Frog philosophize")
}

abstract class Animal {
  def name: String
}

trait HasLegs {
  def walk() = println("Walking")
}

/**
 * 如果想把特质混入到显式扩展超类的类里，可以用extends指明待扩展的超类，用with混入特质
 * @param name
 */
class Rabbit(val name: String) extends Animal with Philosophical with HasLegs {
  override def toString: String = "rabbit"

  override def philosophize(): Unit = println("Rabbit philosophize")
}
